/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.openbrew.openbrewrf;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author dchapman
 */
@Entity
@Table(name = "OBReminder")
@XmlRootElement
public class OBReminder implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ReminderID")
    private Integer reminderID;
    @Basic(optional = false)
    @NotNull
    @Size(min = 0, max = 250)
    @Column(name = "ReminderText")
    private String reminderText;
    @Basic(optional = false)
    @NotNull
    @Column(name = "ReminderDate")
    @Temporal(TemporalType.TIMESTAMP)
    private Date reminderDate;
    @Basic(optional = false)
    @NotNull
    @Column(name = "RepetitionType")
    private int repetitionType;
    @OneToMany(cascade=CascadeType.REFRESH, fetch=FetchType.EAGER)
    @JoinTable(
        name="JTRmdrToAlarm",
        joinColumns={ @JoinColumn(name="ReminderID", referencedColumnName="ReminderID")},
        inverseJoinColumns={ @JoinColumn(name="AlarmID", referencedColumnName="AlarmID", unique=true)}
    )
    private List<OBAlarm> alarmCollection;

    public OBReminder() {
    }

    public OBReminder(Integer reminderID) {
        this.reminderID = reminderID;
    }

    public OBReminder(Integer reminderID, String reminderText, Date reminderDate, int repetitionType) {
        this.reminderID = reminderID;
        this.reminderText = reminderText;
        this.reminderDate = reminderDate;
        this.repetitionType = repetitionType;
    }

    public Integer getReminderID() {
        return reminderID;
    }

    public void setReminderID(Integer reminderID) {
        this.reminderID = reminderID;
    }

    public String getReminderText() {
        return reminderText;
    }

    public void setReminderText(String reminderText) {
        this.reminderText = reminderText;
    }

    public Date getReminderDate() {
        return reminderDate;
    }

    public void setReminderDate(Date reminderDate) {
        this.reminderDate = reminderDate;
    }

    public int getRepetitionType() {
        return repetitionType;
    }

    public void setRepetitionType(int repetitionType) {
        this.repetitionType = repetitionType;
    }

    public List<OBAlarm> getAlarmCollection() {
        return alarmCollection;
    }

    public void setAlarmCollection(List<OBAlarm> alarmCollection) {
        this.alarmCollection = alarmCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (reminderID != null ? reminderID.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Movement)) {
            return false;
        }
        OBReminder other = (OBReminder) object;
        if ((this.reminderID == null && other.reminderID != null) || (this.reminderID != null && !this.reminderID.equals(other.reminderID))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.openbrew.openbrewrf.OBReminder[ reminderID=" + reminderID + " ]";
    }
    
}
